package doy01_period;

import java.time.LocalDate;
import java.time.Period;
import java.time.temporal.ChronoUnit;

public class Test {
    public static void main(String[] args) {
        //计算两个时间的间隔
        //计算自己和未来女朋友的生日间隔
        LocalDate birthday = LocalDate.of(1999, 5, 5);
        LocalDate girl = LocalDate.of(2000, 5, 5);
        Period between = Period.between(birthday, girl);
        System.out.println(between.getYears());
        System.out.println(between.getMonths());
        System.out.println(between.getDays());
        System.out.println("---------------");
        long until = birthday.until(girl, ChronoUnit.DAYS);
        System.out.println(until);
        System.out.println("---------------");
        LocalDate date = LocalDate.of(2002,12,23);
        LocalDate date1 = LocalDate.of(2025,7,12);
        Period between1 = Period.between(date, date1);
        System.out.println(between1.getYears());
        System.out.println(between1.getMonths());
        System.out.println(between1.getDays());
        System.out.println("您已经活了："+between1.getYears()+"年"+between1.getMonths()+"月"+between1.getDays()+"天");
    }
}
